package com;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
	public Connection conn ;
	
	public DBConnection(String className, String url, String userName, String password){
		getConn(className, url, userName, password) ;
	}
	
	public Connection getConn(String className, String url, String userName, String password) {
		try{
			Class.forName(className) ;
			conn= DriverManager.getConnection(url,userName,password); 
		}catch (Exception e) {
			e.printStackTrace() ;
		}
		return conn ;
	}

	public Connection getConn() {
		return conn;
	}

	public void setConn(Connection conn) {
		this.conn = conn;
	}

	public void closeConn() {
		try{
			conn.close() ;
		}catch (Exception e) {
			e.printStackTrace() ;
		}
	}
}
